package com.evl.api.ticketCheckStation.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.evl.api.ticketCheckStation.service.ITicketCheckStationService;
import com.evl.common.controller.BaseController;
import com.evl.common.persistence.model.TicketCheckStation;
import com.evl.core.vo.BaseResultVo;
import com.evl.core.vo.JsonReturnHelper;

/**
 * 检票控制器
 *
 * @author 
 * @Date 2017-07-13 18:19:48
 */
@Controller
@RequestMapping("/api/ticketCheckStation")
public class ApiTicketCheckStationController extends BaseController {

	@Resource
	ITicketCheckStationService checkStationService;
	 /**
     * 获取检票站点列表
	 * @throws Exception 
     */
    @ApiOperation("获取检票站点列表")
    @RequestMapping(value = "/getCheckStation", method = RequestMethod.GET,produces = "application/json; charset=utf-8")
    @ResponseBody
    public BaseResultVo getCheckStation(
			@ApiParam(required = true, name = "ticketId", value = "车票id")
			@RequestParam(required=true) String ticketId) throws Exception {
    	
    	List<TicketCheckStation> list= checkStationService.getCheckStations(ticketId);
    	
    	return JsonReturnHelper.getSuccessWithData(list);
    	
    }
    
    /**
     * 执行检票
	 * @throws Exception 
     */
    @ApiOperation("执行检票")
    @RequestMapping(value = "/checkTicket", method = RequestMethod.POST,produces = "application/json; charset=utf-8")
    @ResponseBody
    public BaseResultVo checkTicket(
			@ApiParam(required = true, name = "id", value = "id")
			@RequestParam(required=true) String id,
			@ApiParam(required = true, name = "openid", value = "openid")
			@RequestParam(required=true) String openid) throws Exception {
    	
    	checkStationService.checkTicket(id,openid);
    	
    	return JsonReturnHelper.getSuccessWithNull();
    	
    }
}
